<script setup>
import NavigationBar from "@/views/Common/NavigationBar.vue";
import PageFooter from "@/views/Common/PageFooter.vue";
import PageHeader from "@/views/Common/PageHeader.vue";
import NavigationBarStricky from "@/views/Common/NavigationBarSticky.vue";
import {useUserStore} from "@/stores/user.js";
import {onMounted} from "vue";
import {getUserShopAPI, getUserInfoAPI} from "@/apis/user.js";
import {getOrderListAPI} from "@/apis/order.js";
import {getAddressListAPI} from "@/apis/address.js";
import {useAddressStore} from "@/stores/address.js";


onMounted(()=>{
  if(useUserStore().isLogin){
    updateInfo()
  }
})

const updateInfo=()=>{
  getUserInfoAPI(useUserStore().userInfo.uid).then((userRes)=>{
    if(userRes.code===200){
      useUserStore().alterUserInfo(userRes.data)
    }
  })
  getAddressListAPI(useUserStore().userInfo.uid).then((res)=>{
    if(res.code===200){
      useAddressStore().loadAddressList(res.data)
    }
  })
 getUserShopAPI(useUserStore().userInfo.uid).then((userShopRes)=>{
   if(userShopRes.code===200){
     useUserStore().loadShop(userShopRes.data)
   }
 })
  getOrderListAPI(useUserStore().userInfo.uid).then((res)=>{
    if(res.code===200){
      useUserStore().loadOrderList(res.data)
    }
  })

}

</script>

<template>
  <NavigationBarStricky></NavigationBarStricky>
  <PageHeader></PageHeader>
    <navigation-bar></navigation-bar>
  <div class="panel">
<!--    二级路由出口-->
    <router-view class="content"></router-view>
  </div>
    <PageFooter></PageFooter>
</template>

<style lang="less" scoped>
.panel {
  background-color: #f5f5f5; // 添加浅灰色背景
  padding:0 100px 30px 100px;
  display: flex;
  justify-content: center;
}
.content{

}

</style>